<?php


namespace App\Http\Middleware;

use App\Http\Controllers\BaseController;
use Closure;
use Illuminate\Support\Facades\Cache;

class Login extends BaseController
{
    public function handle($request, Closure $next)
    {
        $token = $request->get('token');
        $request->cache_data = Cache::get($token);

        if (!$request->cache_data) {
            return $this->returnJson(BaseController::UNAUTHORIZED, 'unauthorized');
        }

        return $next($request);
    }
}
